package com.google.code.mochaccino.framework.ui.components.table;

/*
 * Copyright 2012 Claude Houle claude.houle@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
public class Cell {

	/** The Column Id */
	private String columnId;

	/** Replace localizable data by a component */
	private String data;

	/** There is an href defined. Therefore clickling on the cell should trigger a browser/url. */
	private String href;

	/** The data content is an image path... */
	private boolean dataIsImage = false;

	/** Set Visible */
	private boolean visible = true;

	/** Size in Px */
	private int sizeInPx = 100;

	/** Constructor with some component content */
	public Cell( String columnId, String content ) {
		super();
		this.columnId = columnId;
		this.data = content;
		if ( columnId == null ) {
			throw new IllegalArgumentException( "columnId cannot be null!" );
		}
	}

	@Override
	public boolean equals( Object o ) {
		if ( o instanceof Cell ) {
			Cell opt = (Cell) o;
			if ( columnId.equals( opt.columnId ) ) {
				return true;
			}
		}
		return super.equals( o );
	}

	/** @return the colId */
	public String getColumnId() {
		return columnId;
	}

	/** @param colId the colId to set */
	public void setColumnId( String colId ) {
		this.columnId = colId;
	}

	/** @return the data content */
	public String getData() {
		return data;
	}

	/** @param content the data content to set */
	public void setData( String content ) {
		this.data = content;
	}

	public String getHref() {
		return href;
	}

	public void setHref( String href ) {
		this.href = href;
	}

	/** @return the sizeInPx */
	public int getSizeInPx() {
		return sizeInPx;
	}

	/** @param sizeInPx the sizeInPx to set */
	void setSizeInPx( int sizeInPx ) {
		this.sizeInPx = sizeInPx;
	}

	@Override
	public int hashCode() {
		return columnId.hashCode();
	}

	public boolean isDataIsImage() {
		return dataIsImage;
	}

	public void setDataIsImage( boolean dataIsImage ) {
		this.dataIsImage = dataIsImage;
	}

	/** @return the visible */
	public boolean isVisible() {
		return visible;
	}

	public void setVisible( boolean value ) {
		visible = value;
	}

	@Override
	public String toString() {
		return columnId;
	}
}